package com.yealove.lunchparty.bean;

import java.io.Serializable;

/**
 * 分页bean
 * User: yealove
 * Date: 14-10-18
 * Time: 下午1:59
 * Created with IntelliJ IDEA.
 */
public class PageBean implements Serializable {

    private static final long serialVersionUID = 6921661392987334380L;

    /** 当前第几页（默认第一页） */
    private int currPage = 1;

    /** 总页数 */
    private int pageCount;

    /** 数据总数 */
    private int totalCount;

    /** 每页数据条数（默认10） */
    private int pageNum = 10;

    /** 分页开始索引 */
    private int startIndex;

    public int getCurrPage() {
        return currPage;
    }

    public void setCurrPage(int currPage) {
        this.currPage = currPage;
    }

    public int getPageCount() {
        //整数部分
        int c = totalCount / pageNum;
        //余数部分
        int y = totalCount % pageNum;
        return y == 0 ? c : c + 1;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getStartIndex() {
        startIndex = (currPage - 1) * pageNum;
        if (startIndex <= 0) {
            return 0;
        }
        if (startIndex >= totalCount) {
            return startIndex - pageNum;
        }
        return startIndex;
    }

    public void setStartIndex(int startIndex) {
        this.startIndex = startIndex;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }
}
